itcao = function(){
	return {
		/**
		 * 判断该字符串是否是空
		 * str 要判断的字符串
		 */
		isNull : function (str) {
			var _str = str + "";
			if(_str == undefined || _str == "undefined" || _str == "null" || _str == null || _str.trim().length == 0){
				return "";
			}else {
				return str;
			}
		},
		/**
		 * 判断是否是json类型
		 * 是 返回true
		 * 否 返回false
		 */
		isJson : function(obj) {
			if(this.isNull(obj + "")  == "")
				return false;
			var isjson = typeof(obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() == "[object object]" && !obj.length; 
			return isjson;
		},
		itcaoStringToBoolean : function(obj) {
			this.isJson(obj);
			if(obj != "") {
				return (/^true$/i).test(obj);
			}
		},
		/**
		 * 日期格式化
		 */
		itDateFormat : function(_date, _fmt) {
			var o = {   
					"M+" : _date.getMonth()+1,                 //月份   
					"d+" : _date.getDate(),                    //日   
					"h+" : _date.getHours(),                   //小时   
					"m+" : _date.getMinutes(),                 //分   
					"s+" : _date.getSeconds(),                 //秒   
					"q+" : Math.floor((_date.getMonth()+3)/3), //季度   
					"S"  : _date.getMilliseconds()             //毫秒   
			};
			if(/(y+)/.test(_fmt))   
				_fmt = _fmt.replace(RegExp.$1, (_date.getFullYear()+"").substr(4 - RegExp.$1.length));   
			for(var k in o)   
				if(new RegExp("("+ k +")").test(_fmt))   
					_fmt = _fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));   
			return _fmt;
		},
		/**
		 * 自动拼装Form表单进行序列化
		 * 支持input属性和select属性
		 * 支持name=value
		 */
		itFormNameIsValue : function(_form) {
			var str = "";
			var inputs = $(_form + " input");
			var selects = $(_form + " select");
			if(inputs.length != 0){
				for(var i=0; i<inputs.length; i++) {
					if($(inputs[i]).attr("type") == "text" || $(inputs[i]).attr("type") == "hidden" || $(inputs[i]).attr("type") == "password" || ($(inputs[i]).val().trim().length > 0 && $(inputs[i]).attr("type") == "checkbox")) {
						str += $(inputs[i]).attr("name") + "=" + inputs[i].value + "&";
					}else if($(inputs[i]).attr("type") == "checkbox") {
						if($(inputs[i]).is(":checked")) {
							str += $(inputs[i]).attr("name") + "=" + "on" + "&";
						}else {
							str += $(inputs[i]).attr("name") + "=&";
						}
					}
				}
			}
			if(selects.length != 0){
				for(var i=0; i<selects.length; i++) {
					str += $(selects[i]).attr("name") + "=" + selects[i].value + "&";
				}
			}
			return str.substring(0, str.length - 1);
		},
		/**
		 * 自动拼装Form表单进行序列化
		 * 支持input属性和select属性
		 * 支持URL编码encodeURIComponent
		 */
		itFormNameIsValueEncodeURIComponent : function(_form) {
			var str = "";
			var inputs = $(_form + " input");
			var selects = $(_form + " select");
			if(inputs.length != 0){
				for(var i=0; i<inputs.length; i++) {
					if($(inputs[i]).attr("name") != undefined) {
						if($(inputs[i]).attr("type") == "text" || $(inputs[i]).attr("type") == "hidden" || $(inputs[i]).attr("type") == "password" || ($(inputs[i]).val().trim().length > 0 && $(inputs[i]).attr("type") == "checkbox")) {
							str += $(inputs[i]).attr("name") + "=" + encodeURIComponent(inputs[i].value) + "&";
						}else if($(inputs[i]).attr("type") == "checkbox") {
							if($(inputs[i]).is(":checked")) {
								str += $(inputs[i]).attr("name") + "=" + encodeURIComponent("on") + "&";
							}else {
								str += $(inputs[i]).attr("name") + "=&";
							}
						}
					}
				}
			}
			if(selects.length != 0){
				for(var i=0; i<selects.length; i++) {
					if($(inputs[i]).attr("name") != undefined) {
						str += $(selects[i]).attr("name") + "=" + encodeURIComponent(selects[i].value) + "&";
					}
				}
			}
			return str.substring(0, str.length - 1);
		},
		/**
		 * ajax获取数据  使用异步且延迟获取数据方式
		 */
		itGetAjaxData : function(url, i) {
			var defer = new jQuery.Deferred();
			$.ajax({
				url : url,
				type : "POST",
				cache : false,
				dataType : "text",
			}).done(function(data) {
				defer.resolve(data, i);
			});
			return defer.promise();
		},
		/**
		 * ajax获取数据  使用同步且延迟获取数据方式
		 */
		itGetAsyncAjaxData : function(url, i) {
			var defer = new jQuery.Deferred();
			$.ajax({
				url : url,
				type : "POST",
				cache : false,
				dataType : "text",
				async: false,
			}).done(function(data) {
				defer.resolve(data, i);
			});
			return defer.promise();
		},
		/**
		 * Ajax获取数据  使用异步延迟获取数据
		 * 支持大数据
		 */
		itGetAjaxBigData : function(url, datas, i) {
			var defer = new jQuery.Deferred();
			if(this.isNull(datas) == ""){
				datas = "[]";
			}
			$.ajax({
				url : url,
				type : "POST",
				cache : false,
				dataType : "text",
				data : datas,
			}).done(function(data) {
				defer.resolve(data, i);
			}).fail(function() {
				alert("服务器发生错误.");
			});
			return defer.promise();
		},
		/**
		 * Ajax获取数据 异步获取
		 * 支持图片上传
		 */
		itcaoGetImageAjaxData : function(url, formData, i) {
			var defer = new jQuery.Deferred();
			$.ajax({
				url: url,
				type: 'POST',
				cache: false,
				data: formData,
				processData: false,
				contentType: false,
			}).done(function(data) {
				defer.resolve(data, formData, i);
			})
			return defer.promise();
		},
		// 数据下标删除, 注意该方法会返回一个新的数组
		itArrayDel : function(arr, n) {
			//prototype为对象原型，注意这里为对象增加自定义方法的方法。
			if(n<0)
				return arr;
			else
				return arr.slice(0,n).concat(arr.slice(n+1,arr.length));
		},
		// 数组去重复 注意该方法返回一个新的数组
		itArrayDeDuplication : function(arr) {
			var res = [];
			var json = {};
			for(var i = 0; i < arr.length; i++){
				if(!json[arr[i]]){
					res.push(arr[i]);
					json[arr[i]] = 1;
				}
			}
			return res;
		},
		// 将form表转换成json
		itFormToJson : function(jQueryEml) {
			var o = {};  
	        var a = jQueryEml.serializeArray();  
	        $.each(a, function () {  
	            if (o[jQueryEml.name]) {  
	                if (!o[jQueryEml.name].push) {  
	                    o[jQueryEml.name] = [o[jQueryEml.name]];  
	                }  
	                o[jQueryEml.name].push(jQueryEml.value || '');  
	            } else {  
	                o[jQueryEml.name] = jQueryEml.value || '';  
	            }  
	        });  
	        return o;  
		},
		// 从json中取出带变量的name值
		itTransformationVar : function(json, dim) {
			return eval("json." + dim);
		},
		// 使用javascript获取项目路径
		itJavaScriptPaths : function() {
			var curPath = window.document.location.href;
		    var pathName = window.document.location.pathname;
		    var pos = curPath.indexOf(pathName);
		    var localhostPath = curPath.substring(0, pos);
		    var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
			var paths =  (localhostPath + projectName);//发布前用此
			return paths;
		},
		itcaoWindow : function (optionsAtt) {
			if($(".itcaoWinZdShow").length > 0)
				$(".itcaoWinZdShow").remove();
			if($(".itcaoNewWin").length > 0)
				$(".itcaoNewWin").remove();
			var option = {
					window_isZb : true, //  是否显示遮挡
					window_width: "1000px", // 实际窗口的宽度
					window_height : "700px", // 实际窗口的高度
					window_btInfo : "新窗口", // 新窗口的title名称
					window_isClose : true, // 是否显示关闭按钮
					window_baColor : "#FFF", // 新窗口的背景
					window_btBaColor : "#09F",// 新窗口title的背景
					window_htmlEmel : "", // html内容的根元素
					window_html : "<div style='font-size:16px;'>此处可以加入javascript css html 内容</div>", // 将哪些html内容加入到新窗口中
					window_Outside : true,
					window_closeFun : function(){}, // 窗口在关闭的时候 调用方法
					window_winBoRadius : "10px", // 新窗口的圆角
					window_winBoshadow : "0px 0px 8px #03F",// 新窗口的边框发光效果
					window_winBorder : "1px solid ", // 新窗口边框样式
					window_moveTransparency : "1", // 移动时的透明度
					window_stopTransparency : "1", // 移动后的透明度
					window_marginLeft : "", // X移动
					window_MarginTop : "", // Y移动
			}
			if(this.isNull(optionsAtt) != "") {
				if(this.isJson(optionsAtt)){
					// 覆盖函数 将用户传递过来的属性覆盖到默认属性中
					$.each(option, function(key, val) {
						if(eval("optionsAtt." + key) != undefined) {
							option[key] = eval("optionsAtt." + key);
						}
					})
				}else {
					this.itDivDaing("您传递的json属性不正确.");
					return;
				}
			}
			
			if(this.itcaoStringToBoolean(option.window_Outside) == false && option.window_Outside != "false")
				option.window_Outside = true;
			else
				option.window_Outside = this.itcaoStringToBoolean(option.window_Outside);
			//给option的html属性赋值
			option.window_html = option.window_htmlEmel.html().trim(); // 赋值
			// 覆盖元素后 清除数据源
			option.window_htmlEmel.empty(); // 清除
			if(option.window_marginLeft == "") // 判断X轴
				option.window_marginLeft = ($(window).width() - option.window_width.replace(/px/g, '')) / 2;
			if(option.window_MarginTop == "") // 判断Y轴
				option.window_MarginTop = ($(window).height() - option.window_height.replace(/px/g, '')) / 2;
			var newWinJson_Win = undefined;
			if(typeof option.window_isZb === 'boolean' && option.window_isZb == true){//判断是否开启遮蔽
				newWinJson_Win = "<div class='itcaoWinZdShow' style='position:fixed;width:100%;height:100%;opacity:1.0;filter:alpha(opacity=60); position:fixed;_position:absolute;'> " + 
					"<div class='itcaoNewWin' style='position:fixed;border-radius:"+option.window_winBoRadius+";-webkit-border-radius:"+option.window_winBoRadius+";-zom-border-radius:"+option.window_winBoRadius+";background:"+option.window_baColor+";border:"+option.window_winBorder+";width:"+option.window_width+";height:"+option.window_height+";box-shadow:"+option.window_winBoshadow+";-webkit-box-shadow:"+option.window_winBoshadow+";-zom-box-shadow:"+option.window_winBoshadow+";'> " + 
						"<div class='itcaoWinMouseMove' style='height:30px;line-height:30px;text-indent:10px;background:"+option.window_btBaColor+";border-radius:"+option.window_winBoRadius+" "+option.window_winBoRadius+" 0px 0px;-webkit-border-radius:"+option.window_winBoRadius+" "+option.window_winBoRadius+" 0px 0px;-zom-border-radius:"+option.window_winBoRadius+" "+option.window_winBoRadius+" 0px 0px;'>" +
							"<div style='float:left;margin-left:1%;'>"+option.window_btInfo+"</div>" +
							"<div style='float:right;margin-right:1%;'><a class='itcaoWinClose' style='font-size:21px;color:#FFF;'>&times;</a></div>" +
						"</div>" +
						"<div>"+option.window_html+"</div>" +
					"</div>" + 
				"</div>";
			}else{ // 如果不是则直接给摊开界面
				newWinJson_Win = "<div class='itcaoNewWin' style='position:fixed;border-radius:"+option.window_winBoRadius+";-webkit-border-radius:"+option.window_winBoRadius+";-zom-border-radius:"+option.window_winBoRadius+";background:"+option.window_baColor+";border:"+option.window_winBorder+";width:"+option.window_width+";height:"+option.window_height+";box-shadow:"+option.window_winBoshadow+";-webkit-box-shadow:"+option.window_winBoshadow+";-zom-box-shadow:"+option.window_winBoshadow+";'>"+
				"<div class='itcaoWinMouseMove' style='height:30px;line-height:30px;text-indent:10px;background:"+option.window_btBaColor+";border-radius:"+option.window_winBoRadius+" "+option.window_winBoRadius+" 0px 0px;-webkit-border-radius:"+option.window_winBoRadius+" "+option.window_winBoRadius+" 0px 0px;-zom-border-radius:"+option.window_winBoRadius+" "+option.window_winBoRadius+" 0px 0px;'>" +
					"<div style='float:left;margin-left:1%;'>"+option.window_btInfo+"</div>" +
					"<div style='float:right;margin-right:1%;'><a class='itcaoWinClose' style='font-size:21px;color:#FFF;'>&times;</a></div>" +
				"</div>" +
				"<div>"+option.window_html+"</div>" +
				"</div>";
			}
			$("body").append(newWinJson_Win);
			if($(".itcaoWinZdShow").length > 0)
				$(".itcaoWinZdShow").css({left : 0, top : 0});
			$(".itcaoNewWin").css({left : option.window_marginLeft, top : option.window_MarginTop});
			$(".itcaoWinClose").on({
				mousemove : function() {
					$(this).css({"color":"red","cursor":"pointer"});
				},
				mouseout : function() {
					$(this).css({"color":"#FFF","cursor":"pointer"});
				},
				click : function() {
					// 关闭元素后 将原数据还原
					option.window_htmlEmel.html(option.window_html); // 还原
					if(typeof(eval(option.window_closeFun)) === "function"){
						option.window_closeFun();
					}
					if(typeof option.window_isZb === 'boolean' && option.window_isZb == true){
						$(".itcaoWinZdShow").remove();
					}else {
						$(".itcaoNewWin").remove();
					}
				}
			});
			if(typeof option.window_isZb === 'boolean' && option.window_isZb == true)
				return {"closeClass" : "itcaoWinClose", "newWinClass" : "itcaoNewWin", "newWinShelter" : "itcaoWinZdShow"};
			else
				return {"closeClass" : "itcaoWinClose", "newWinClass" : "itcaoNewWin"};
		}
	}
}();